package com.yfp.tissue.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.core.web.page.TableDataInfo;
import com.yfp.common.log.annotation.Log;
import com.yfp.common.log.enums.BusinessType;
import com.yfp.common.security.annotation.RequiresPermissions;
import com.yfp.tissue.domain.entity.PositionType;
import com.yfp.tissue.service.PositionTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @PROJECT_NAME: ydyfp
 * @DESCRIPTION:
 * @USER: xiaohuya
 * @DATE: 2023/12/19 16:01
 */

@RestController
@RequestMapping("/positionType")
@Tag(name = "点位类型管理")
public class PositionTypeController extends BaseController {


    @Resource
    private PositionTypeService positionTypeService;

    /**
     * 点位类型查询
     */
    @GetMapping("positionConditions")
    @Operation(summary = "点位类型查询")
    @Log(title = "点位类型查询", businessType = BusinessType.QUERY)
    @RequiresPermissions("tissue:positionType:list")

    public TableDataInfo<PositionType> positionConditions(@RequestParam(value = "positionTypeId", required = false) String positionTypeId, @RequestParam(value = "enable", required = false) String enable
            ,@RequestParam(value = "cityName",required = false) String cityName, @RequestParam(value = "type", required = false) Integer type) {
        startPage();
        PositionType positionType = new PositionType();
        positionType.setPositionTypeId(positionTypeId);
        positionType.setEnable(enable);
        positionType.setCityName(cityName);
        positionType.setType(type);
        return getDataTable(positionTypeService.queryDetail(positionType));

    }

    /**
     * 点位类型添加
     */
    @PostMapping("addPositionType")
    @Operation(summary = "点位类型添加")
    @Log(title = "点位类型添加", businessType = BusinessType.INSERT)
    @RequiresPermissions("tissue:positionType:add")

    public R addPositionType(@RequestBody PositionType positionType) {

        return positionTypeService.addPositionType(positionType);

    }

    /**
     * 点位类型修改
     */
    @PostMapping("updatePositionType")
    @Operation(summary = "点位类型修改")
    @Log(title = "点位类型修改", businessType = BusinessType.UPDATE)
    @RequiresPermissions("tissue:positionType:edit")

    public R updatePositionType(@RequestBody PositionType positionType) {

        return positionTypeService.updatePositionType(positionType);

    }

    /**
     * 点位类型添加
     */
    @PostMapping("updatePositionTypeStatus")
    @Operation(summary = "点位类型状态修改")
    @Log(title = "点位类型状态修改", businessType = BusinessType.UPDATE)
    @RequiresPermissions("tissue:positionType:dis")

    public R updatePositionTypeStatus(@RequestBody PositionType positionType) {


        return positionTypeService.updatePositionTypeStatus(positionType);

    }
}
